# # 基本捕获语法
# try:
#     f = open("D:/abc.txt","r",encoding="UTF-8")
# except:
#     print("error,because it don't excite.我将open模式，改为w模式去打开")
#     f = open("D:/abc.txt", "w", encoding="UTF-8")
#
# # 捕获制定异常
# try:
#     print(name)
#     # 1 / 0
# except NameError as e:
#     print('出现了变量未定义的异常')
#     print(e)
#
# # 捕获多个异常
# try:
#     # 1 / 0
#     print(name)
# except(NameError,ZeroDivisionError) as e:
#     print('出现了变量未定义 或者 除以0的异常错误')
#
# 未正确设置捕获异常类型


# 捕获所有异常
try:
    print('hello')

except Exception as e:
    print('出现异常了')
else:
    print('好搞笑，你不会真的以为没有异常吧！好吧是没有异常')
finally:
    print('这个是无论有异常还是无异常都会显示出来的内容')